<!--投资方-->
<template>
    <div>
        <el-form :inline="true" ref="form" :model="form">
            <el-form-item label="企业名称" prop="name">
                <el-input placeholder="企业名称" v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="企业类型" prop="companyId">
                <!--<el-select v-model="form.companyId">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.companyTypelist"></el-option>-->
                <!--</el-select>-->
                <el-select v-model="form.companyId">
                    <el-option label="事业单位" value="0" ></el-option>
                    <el-option label="央企" value="1" ></el-option>
                    <el-option label="国企" value="2" ></el-option>
                    <el-option label="外企" value="3" ></el-option>
                    <el-option label="合资" value="4" ></el-option>
                    <el-option label="民营企业" value="5" ></el-option>
                    <el-option label="其他" value="6" ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="上市情况" prop="inmarketId">
                <!--<el-select v-model="form.inmarketId">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.inmarketList"></el-option>-->
                <!--</el-select>-->
                <el-select v-model="form.inmarketId">
                    <el-option label="非上市" value="0" ></el-option>
                    <el-option label="沪深A股" value="1" ></el-option>
                    <el-option label="上证A股" value="2" ></el-option>
                    <el-option label="中小板" value="3" ></el-option>
                    <el-option label="创业板" value="4" ></el-option>
                    <el-option label="新三板" value="5" ></el-option>
                    <el-option label="港股" value="6" ></el-option>
                    <el-option label="纳斯达克" value="7" ></el-option>
                    <el-option label="其他" value="8" ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="涉及领域" prop="field0Id">
                <!--<el-select v-model="form.field0Id" size="small" style="width:120px" @change="change()">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.involvedfieldList0" :key="item.value" >-->
                    <!--</el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item  prop="field1Id">-->
                <!--<el-select v-model="form.field1Id" size="small" style="width:120px" @change="changeThree()" v-if="form.secondLevel.length">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.secondLevel"></el-option>-->
                <!--</el-select>-->
            <!--</el-form-item>-->
            <!--<el-form-item  prop="field2Id">-->
                <!--<el-select v-model="form.field2Id" size="small" style="width:120px" v-if="form.secondLevel.length&&form.thirdLevel.length">-->
                    <!--<el-option :label="item.name" :value="item.id" v-for="item in form.thirdLevel"></el-option>-->
                <!--</el-select>-->
                <el-select v-model="form.field0Id" >
                    <el-option label="集中热水供应" value="0" ></el-option>
                    <el-option label="大型公共建筑节能" value="1" ></el-option>
                    <el-option label="农业废弃物资源化利用" value="2" ></el-option>
                    <el-option label="餐厨垃圾处理" value="3" ></el-option>
                    <el-option label="生活垃圾焚烧发电" value="4" ></el-option>
                    <el-option label="市政污泥集中处理" value="5" ></el-option>
                    <el-option label="农林生物质发电" value="6" ></el-option>
                    <el-option label="建筑垃圾资源化处理" value="7" ></el-option>
                    <el-option label="废旧轮胎资源化利用" value="8" ></el-option>
                    <el-option label="光伏发电" value="6" ></el-option>
                    <el-option label="区域能源解决方案" value="7" ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="客户经理" prop="manager">
                <el-select v-model="form.date1">
                    <el-option :label="item.name" :value="item.id" v-for="item in companyTypelist"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="联系电话" prop="phone">
                <el-input placeholder="联系电话" v-model="form.phone"></el-input>
            </el-form-item>
            <el-form-item label="企业星级" prop="star">
                <el-select v-model="form.star">
                    <el-option label="一星" value="0"></el-option>
                    <el-option label="二星" value="1"></el-option>
                    <el-option label="三星" value="2"></el-option>
                    <el-option label="四星" value="3"></el-option>
                    <el-option label="五星" value="4"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="resetForm('form')">重置</el-button>
            </el-form-item>
            <el-form-item>
                <el-button type="primary">查找</el-button>
            </el-form-item>
        </el-form>
        <div class="dateMsg">总计<b>567</b>条数据</div>
        <div>
            <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="name" label="名称">
                </el-table-column>
                <el-table-column prop="type" label="类型">
                </el-table-column>
                <el-table-column prop="shangshi" label="上市情况">
                </el-table-column>
                <el-table-column prop="field" label="涉及领域">
                </el-table-column>
                <el-table-column prop="power" label="投资星级">
                </el-table-column>
                <el-table-column prop="time" label="编辑时间">
                </el-table-column>
                <el-table-column prop="editMan" label="编辑人">
                </el-table-column>
                <el-table-column prop="manager" label="客户经理">
                </el-table-column>
                <el-table-column prop="date" label="操作" mi>
                    <template scope="scope">
                        <el-button  type="text" size="small" @click="showDio('checkDiolage')">审核</el-button>
                        <!--<el-button type="text" size="small" @click="handleEdit('editDiolage',scope.$index, scope.row)">编辑</el-button>-->
                        <el-button type="text" size="small" @click="del">弃置此副本</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div  style="width:200px;margin-left:80%;margin-top: 10px">
                <el-pagination
                        layout="prev, pager, next"
                        :total="50">
                </el-pagination>
            </div>
        </div>
        <!--审核企业-->
        <el-dialog title="审核企业" :visible.sync="dialogeShow.checkDiolage" :modal="false" size="small" v-if="dialogeShow.checkDiolage">
            <compCheck></compCheck>
        </el-dialog>
        <!--编辑企业-->
        <el-dialog title="编辑企业" :visible.sync="dialogeShow.editDiolage" :modal="false" size="small" v-if="dialogeShow.editDiolage">
            <compEdit></compEdit>
        </el-dialog>
    </div>
</template>
<script>
    import _http from '@/components/common/http.vue'
    import Bus from '@/config/bus.js'
    import compCheck from '@/components/working/common/compCheck.vue'
    import compEdit from '@/components/working/common/compEdit.vue'
    export default{
        components:{compCheck,compEdit},
        data(){
            return{
                apiPort:{
//                    企业类型接口
                    companytypeApi:'BASEURL/adminApi/dicTree?type=2',
//                    上市情况接口
                    inmarketApi:'BASEURL/adminApi/dicTree?type=3',
//                    涉及领域接口
                    involvedfieldApi:'BASEURL/adminApi/dicTree?type=5',
//                    客户经理字段接口
                    customerManager:'',
//                    设计资质字典接口
                    designaptitudeApi:'BASEURL/adminApi/dicTree?type=6'
                },
                companyTypelist:[],
                form: {
                    //                  设计资质字典数据
                    designaptitudeList:'',
                    //                企业类型接口字典
                    companyTypelist:'',
//                上市情况接口参数
                    inmarketList:'',
//                涉及领域参数
                    involvedfieldList0:'',
                    involvedfieldList1:'',
                    involvedfieldList2:'',
//                涉及领域中间层级
                    secondLevel:[],
//                涉及领域第三层级
                    thirdLevel:[],
                    flag:false,
//                    企业类型id
                    companyId: '',
//                    上市情况id
                    inmarketId:'',
//                    涉及领域一级id
                    field0Id: '',
//                    涉及领域二级id
                    field1Id: '',
//                    涉及领域三级id
                    field2Id: '',
//                    设计领域id
                    designId:'',
                    editMan:'',
                    manager:'',
                    kind:'',
                    name: '',
                    region: '',
                    date1: '',
                    date2: '',
                    delivery: false,
                    type: [],
                    resource: '',
                    desc: '',
                    upS:'',
                    aboutField:'',
                    zKind:"",
                    phone:'',
                    star:'',
                    field:''
                },
                dialogeShow:{
                    checkDiolage:false,
                    editDiolage:false,
                },
                tableData: [{
                    name:"常州天合能源管理有限公司",
                    type: '民营',
                    shangshi:"否",
                    field: '清洁能源',
                    power:"研发",
                    time:"2017.0705",
                    editMan:"王小虎",
                    manager:"王虎"
                },{
                    name:"常州天合能源管理有限公司",
                    type: '民营',
                    shangshi:"否",
                    field: '清洁能源',
                    power:"研发",
                    time:"2017.0705",
                    editMan:"王小虎",
                    manager:"王虎"
                }, {
                    name:"常州天合能源管理有限公司",
                    type: '民营',
                    shangshi:"否",
                    field: '清洁能源',
                    power:"研发",
                    time:"2017.0705",
                    editMan:"王小虎",
                    manager:"王虎"
                }, {
                    name:"常州天合能源管理有限公司",
                    type: '民营',
                    shangshi:"否",
                    field: '清洁能源',
                    power:"研发",
                    time:"2017.0705",
                    editMan:"王小虎",
                    manager:"王虎"
                }]
            }
        },
        mounted(){
            this.getType()
            this.test()
        },
        methods:{
            change(){
                this.form.secondLevel=[]
                for(var a in this.form.involvedfieldList1){
                    if(this.form.field0Id==this.form.involvedfieldList1[a].father_id){
                        console.log(this.form.involvedfieldList1[a])
                        this.form.secondLevel.push(this.form.involvedfieldList1[a])
                    }
                }
            },
//            涉及领域第三级
            changeThree(){
                this.form.thirdLevel=[]
                for(var a in this.form.involvedfieldList2){
                    if(this.form.field1Id==this.form.involvedfieldList2[a].father_id){
                        this.form.thirdLevel.push(this.form.involvedfieldList2[a])
                    }
                }
            },
//            获取字典类型接口
            getType(){
                var that = this
//            获取企业类型字典接口
                _http.axiosGet(that,that.apiPort.companytypeApi,(res)=>{
                    that.form.companyTypelist=res.L0

            })
//            获取上市情况接口
                _http.axiosGet(that,that.apiPort.inmarketApi,(res)=>{
                    that.form.inmarketList=res.L0
                console.log(that.inmarketList)
            })
//            获取领域接口
                _http.axiosGet(that,that.apiPort.involvedfieldApi,(res)=> {
                    that.form.involvedfieldList0 = res.L0
                that.form.involvedfieldList1 = res.L1
                that.form.involvedfieldList2 = res.L2
            })
//                获取设计资质字典数据

                _http.axiosGet(that,that.apiPort.designaptitudeApi,(res)=>{
                    that.form.designaptitudeList=res.L0
            })

            },
            test(){
                var res={
                    "L0": [
                        {
                            "id": 1,				//option值
                            "name": "环保",				//显示名称
                            "father_id": 0				//父级option值
                        },
                        {
                            "id": 2,
                            "name": "节能",
                            "father_id": 0
                        }
                    ],
                    "L1": [
                        {
                            "id": 11,				//option值
                            "name": "废气处理",				//显示名称
                            "father_id": 1				//父级option值
                        },
                        {
                            "id": 551,
                            "name": "固废处理",
                            "father_id": 1
                        },
                        {
                            "id": 11,				//option值
                            "name": "摩托车废气",				//显示名称
                            "father_id": 2				//父级option值
                        },
                        {
                            "id": 551,
                            "name": "汽车废气",
                            "father_id": 2
                        }
                    ],
                    "L2": [
                        {
                            "id": 111,				//option值
                            "name": "111",			//显示名称
                            "father_id": 1				//父级option值
                        },
                        {
                            "id": 1551,
                            "name": "551",
                            "father_id": 551
                        }
                    ]
                }
                this.form.involvedfieldList0 = res.L0
                this.form.involvedfieldList1 = res.L1
                this.form.involvedfieldList2 = res.L2
            },
            //            组件间传参数
            handleEdit(param,index,raw){
                this.showDio(param)
                setTimeout(function(){
                    Bus.$emit('getTarget',raw)
                },100)
                ;
            },
//            重置按钮
            resetForm(formName){
            this.$refs[formName].resetFields();
        },
            showDio(parram){
                this.dialogeShow[parram]=true
            },
            del() {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.$message({
                    type: 'success',
                    message: '删除成功!'
                });
            }).catch(() => {
                    this.$message({
                    type: 'info',
                    message: '已取消删除'
                });
            });
            }
        }
    }
</script>
<style>
    .dateMsg{
        padding-left: 20px;
        color: red;
        padding:10px
    }
</style>